home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* DATABOSS MODULE: EXTFHC.C */
- /****************************************************************************/
-
- #include "db_lsc.h"
-
- #ifdef __TURBOC__
- #include <mem.h>
- #else
- #include <graph.h>
- #include <string.h>
- #endif
- #include <dos.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include "db_types.h"
- #include "db_conio.h"
- #include "db_dmem.h"
- #include "db_dos.h"
- #include "extfhc.h"
-
- /***************************** INTERNAL TYPES *****************************/
-
- typedef byte handlearray[255];
- typedef handlearray *handlearrayptr;
-
- /*************************** INTERNAL VARIABLES ***************************/
-
- static ptr dosmemory;
- static ptr oldint21;
- static handlearrayptr oldhandletable;
- static byte oldnumhandles;
- static handlearray internaltable;
-
- static bool initialized = False;
-
- /***************************** IMPLEMENTATION *****************************/
-
- void extendhandles(void) {
- byteptr p;
-
- if (_osmajor == 2) {
- cwrite(LSC_Unable2Extend); /* SN 3.5 */
- cwrite("\n\r"); /* SN 3.5 */
- getch();
- }
- else {
- dosmemory = (ptr)internaltable;
- if (dosmemory != NULL) {
- memset(dosmemory,0xFF,sizeof(handlearray));
- p = MK_FP(_psp,0x0032);
- oldnumhandles = *p;
- FP_OFF(p) = 0x0034;
- oldhandletable = *((handlearrayptr *) p);
- FP_OFF(p) = 0x0032;
- *p = sizeof(handlearray);
- FP_OFF(p) = 0x0034;
- *((ptr *) p) = dosmemory;
- memmove(dosmemory,oldhandletable,oldnumhandles);
- }
- }
- }
-
- /********************** UNIT INITIALIZATION/EXIT CODE *********************/
-
- void unextendhandles(void) {
- byteptr p;
-
- if (dosmemory != NULL) {
- p = MK_FP(_psp,0x0032);
- *p = oldnumhandles;
- FP_OFF(p) = 0x0034;
- *((ptr *) p) = oldhandletable;
- memmove(oldhandletable,dosmemory,oldnumhandles);
- dosmemory = NULL;
- }
- }
-
- void extfhc_init(void)
- {
- if (!initialized) {
- initialized = True;
- dosmemory = NULL;
- atexit(unextendhandles);
- extendhandles();
- }
- }
-
- /***************************** END OF EXTFHC.C ****************************/
-